<?php

namespace App\Module\Api\Controllers;
use App\Module\Api\Validator\CommonActonValidator;
use App\System\Base\Services\TokenService;
use App\System\Coupon\Repositories\CouponUserRepository;

/**
 *购物券列表
 */
class ShoppingCardListController extends Controller
{
    public function index()
    {
        (new CommonActonValidator())->check();
        $user_id = TokenService::getUserId();
        $action = $this->query->action;
        if(!in_array($action,[1,2]))
        {
            throw new ParamsException([
                'error_code' => '9001',
                'message'    => '请求产数错误',
            ]);
        }
        $user = CouponUserRepository::getInstance();
        $data = $user->getApiList($this->table,$action,$user_id);
        return apiResponse($data);
    }
}
